//
//  BaseViewController.m
//  Pianke
//
//  Created by BetaTheta on 16/1/16.
//  Copyright © 2016年 BetaTheta. All rights reserved.
//

#import "BaseViewController.h"
#import "LeftDrawerController.h"
#import "UIViewController+MMDrawerController.h"
#import "MMDrawerBarButtonItem.h"

@interface BaseViewController ()
@property (nonatomic, retain) UIBarButtonItem *fenleiItem;
@property (nonatomic, retain) UIBarButtonItem *labelItem;
@end

@implementation BaseViewController
- (void)dealloc
{
    [_fenleiItem release];
    [_labelItem release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 背景颜色
    self.view.backgroundColor = [UIColor colorWithRed:242 / 256.0 green:234 / 256.0 blue: 218 / 256.0 alpha:1];
    
    // 导航栏不透明
    self.navigationController.navigationBar.translucent = NO;

    // 导航栏按钮
    
    self.fenleiItem =  [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_fenlei.png"] style:UIBarButtonItemStylePlain target:self action:@selector(leftDrawerAction:)] autorelease];
    
    self.labelItem = [[[UIBarButtonItem alloc] initWithTitle:@"Label" style:UIBarButtonItemStylePlain target:self action:nil] autorelease];

    
    // 添加左按钮
    self.navigationItem.leftBarButtonItems = @[_fenleiItem,_labelItem];
    /**< item颜色 */
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
    
    // 抽屉按钮
    [self setupLeftMenuButton];
    
    
}
// 抽屉触发方法
- (void)setupLeftMenuButton
{
    // 创建按钮
    
//    MMDrawerBarButtonItem *leftDrawerBtn = [[MMDrawerBarButtonItem alloc] initWithTarget:self action:@selector(leftDrawerAction:)];
    
    [self.navigationItem setLeftBarButtonItem:_fenleiItem animated:YES];
    
}
- (void)leftDrawerAction:(id)btn
{
    [self.mm_drawerController toggleDrawerSide:(MMDrawerSideLeft) animated:YES completion:^(BOOL finished) {
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
